package com.hm.ibsm.auto;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @author shishun.wang
 * @date 2017年3月6日 下午6:00:48
 * @version 1.0
 * @describe
 */
@EnableAsync // 配置 @Async 异步生效
@Configuration
@EnableAutoConfiguration
@EnableConfigurationProperties(IbsmProperties.class)
public class WebAutoConfiguration {

	/**
	 * 创建线程池
	 * 
	 * @return
	 */
	@Bean
	public TaskExecutor taskExecutor() {
		ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
		executor.setCorePoolSize(5);
		executor.setKeepAliveSeconds(300);
		executor.setMaxPoolSize(10);
		executor.setQueueCapacity(25);
		return executor;
	}
}
